package com.warrior.superdata.util;

import java.math.BigDecimal;

/**
 * @ClassName com.warrior.operation.monitor.util.BigDecimalUtil.java
 * @Author xujian
 * @Description
 * @CreateTime 2021年04月01日 13:59:00
 */
public class BigDecimalUtil {

    public static BigDecimal divide(BigDecimal var1, BigDecimal divisor, int scale, int roundingMode) {
        if(null != divisor && 0 != divisor.intValue()){
            return var1.divide(divisor,scale,roundingMode);
        }
        return BigDecimal.ZERO;
    }

    public static BigDecimal dividePercent(BigDecimal var1, BigDecimal divisor, int scale, int roundingMode) {
        if(null != divisor && 0 != divisor.intValue()){
            return var1.multiply(new BigDecimal(100)).divide(divisor,scale,roundingMode);
        }
        return BigDecimal.ZERO;
    }

}
